package com.ellricky.excute_president.ui.activity.school

import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.andr.common.widget.refresh.RefreshFlag
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.excute_president.*
import com.ellricky.excute_president.KxAdapter

class KxActivity : BaseRefreshActivity<Void, BasePresenter<Void>, TodayKxEntity>() {

    override fun initUIView() {
        super.initUIView()
        mTvTitle.text = getString(R.string.pd_today_kx)
    }

    override fun getRvAdapter(): BaseRecyclerAdapter<TodayKxEntity> {
        return KxAdapter(this)
    }

    override fun getResponseCallback(): BaseCallback {
        return object : EListCallback<TodayKxEntity>(this) {
            override fun onSuccess(data: MutableList<TodayKxEntity>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(dataSource, refresh)
            }

            override fun onErrorCode(code: String?, msg: String?) {
                super.onErrorCode(code, msg)
                rvView.onRefreshFailed(refresh)
            }

            override fun onHttpError(code: String?, msg: String?) {
                super.onHttpError(code, msg)
                rvView.onRefreshFailed(refresh)
            }
        }
    }

    override fun getUrlPath(): String {
        return API_KX
    }

    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, position: Int, l: Long) {
        super.onItemClick(adapterView, view, position, l)
        val entity = adapter[position]
        EAppUtil.jumpPageWithId(this, KxDetailActivity::class.java, entity.id)
    }

    override fun initParamMap() {

    }

    override fun setRefreshListener() {
        rvView.init(this, RefreshFlag.NONE)
    }

}
